{include file="public/header-static"/}
{include file="public/sidebar"/}
<div id="main">
    {include file="public/header"/}
    <div class="main-content">
        <div class="container">
            <div class="row">
                <div class="col-md-12">
                    <div class="row">


                        <div class="col-md-7">
                            <div class="card bor" style="height: calc( 100% - 15px );">
                                <div class="card-dth">
                                    <div class="user">
                                        <div class="user-name">会员数据</div>
                                    </div>
                                    <div class="u-rig">
                                        <div class="u-left">
                                            <div class="bg-txt">
                                                <text class="j"></text>
                                                <text class="str">本周月会员</text>
                                            </div>
                                            <div class="bg-str">
                                                {$member_data.monthUsersMemberThisWeek}
                                            </div>
                                        </div>

                                        <div class="u-left">
                                            <div class="bg-txt">
                                                <text class="bz"></text>
                                                <text class="str">本周年会员</text>
                                            </div>
                                            <div class="bg-str">
                                                {$member_data.yearsUsersMemberThisWeek}
                                            </div>
                                        </div>

                                        <div class="u-left">
                                            <div class="bg-txt">
                                                <text class="dy"></text>
                                                <text class="str">本月月会员</text>
                                            </div>
                                            <div class="bg-str">
                                                {$member_data.monthUsersMemberThisMonth}
                                            </div>
                                        </div>

                                        <div class="u-left">
                                            <div class="bg-txt">
                                                <text class="jn"></text>
                                                <text class="str">本月年会员</text>
                                            </div>
                                            <div class="bg-str">
                                                {$member_data.yearsUsersMemberThisMonth}
                                            </div>
                                        </div>

                                        <div class="u-left">
                                            <div class="bg-txt">
                                                <text class="j"></text>
                                                <text class="str">本周日会员</text>
                                            </div>
                                            <div class="bg-str">
                                                {$member_data.todayUsersMemberThisWeek}
                                            </div>
                                        </div>

                                        <div class="u-left">
                                            <div class="bg-txt">
                                                <text class="bz"></text>
                                                <text class="str">本月日会员</text>
                                            </div>
                                            <div class="bg-str">
                                                {$member_data.todayUsersMemberThisMonth}
                                            </div>
                                        </div>
                                    </div>
                                    <div class="txt-cen">
                                        <canvas id="post" height="80"></canvas>
                                    </div>
                                </div>
                            </div>
                        </div>


                        <div class="col-md-5">
                            <div class="card bor" style="height: calc( 100% - 15px );">
                                <div class="card-dth">
                                    <div class="user">
                                        <div class="user-name">开通数据</div>
                                    </div>
                                    <div class="d-fix">
                                        <canvas id="state1" width="112" height="112"></canvas>
                                        <canvas id="state2" width="112" height="112"></canvas>
                                        <canvas id="state3" width="112" height="112"></canvas>
                                    </div>
                                    <div class="fix-d">
                                        <div class="d-th">
                                            <div class="numer t">{$open_data.countUsersMember}</div>
                                            <div class="d-str">会员总数</div>
                                            <div class="d-add">已失效会员{$open_data.countInvalidUsersMember}个</div>
                                        </div>
                                        <div class="d-th">
                                            <div class="numer b">{$open_data.monthUsersMember}</div>
                                            <div class="d-str">月会员</div>
                                            <div class="d-add">占总会员的{$open_data.monthUsersMemberScale}</div>
                                        </div>
                                        <div class="d-th">
                                            <div class="numer w">{$open_data.yearsUsersMember}</div>
                                            <div class="d-str">年会员</div>
                                            <div class="d-add">占总会员的{$open_data.yearsUsersMemberScale}</div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>


                    </div>

                </div>
            </div>

            <div class="list">
                <!--                <div class="uname">会员列表</div>-->
                <div class="app-block">
                    <div class="app-content">
                        <div class="app-action">

                            <div class="action-right" style="margin-left: auto;">
                                <a href="#" class="app-sidebar-menu-button btn btn-outline-light">
                                    <i data-feather="menu"></i>
                                </a>
                                <div class="input-group">
                                    <input type="text" name="keywords" id="keywords" autofocus="autofocus"
                                           value="{$Request.get.keywords}" class="form-control"
                                           placeholder="昵称"
                                           aria-describedby="button-addon1">
                                    <div class="input-group-append">
                                        <button class="btn btn-outline-light" type="submit" id="button-addon1">
                                            <i data-feather="search"></i>
                                        </button>
                                    </div>
                                </div>
                            </div>
                        </div>


                        <div class="row">
                            <div class="col-md-12">
                                <div class="card">
                                    <table id="linkstable" lay-filter="linkstable"></table>
                                </div>

                            </div>
                        </div>
                    </div>
                </div>


            </div>
        </div>
    </div>
    {include file="public/footer"/}
</div>
<script src="__STATIC__/vendors/charts/chartjs/chart.min.js"></script>
<script src="__STATIC__/vendors/charts/apex/apexcharts.min.js"></script>
<script src="__STATIC__/vendors/circle-progress/circle-progress.min.js"></script>
<script src="__STATIC__/assets/js/examples/dashboard.js"></script>
<script src="__STATIC__/assets/js/examples/echarts.js"></script>
<script src="__STATIC__/assets/js/custom.js"></script>
<script type="text/html" id="switchTpl">
    <input type="checkbox" name="state" value="{{d.id}}" lay-skin="switch" lay-text="正常|禁用" lay-filter="switch_state" {{
           d.state== 1 ? 'checked' : '' }}>
</script>

<script type="text/html" id="barDemo">
    <button lay-event="upgrade" onclick="upgrade({{d.uid}})" class="btn btn-sm btn-outline-secondary">升级会员</button>
</script>
<script>
    function upgrade(id) {
        layer.prompt({title: '请填写新增天数', formType: 3}, function (text, index) {
            if (text <= 0) {
                return false;
            }
            $.post("{:url('/users/upGradeMember')}", {'id': id, 'day': text}, function (res) {
                if (res['code'] != 1) {
                    toastr.error(res['msg']);
                } else {
                    window.location.reload();
                }
            });

            layer.close(index);
        })
    }

    // layui插件
    layui.use('table', function () {
        var table = layui.table
            , form = layui.form;
        // 表格初始化
        table.render({
            elem: '#linkstable'
            , skin: 'line' //行边框风格
            , even: true //开启隔行背景
            , url: '{:url("/member/index")}'
            , method: 'post'
            , page: true //开启分页
            , cols: [[
                {field: 'nickname_data', title: '头像/昵称'}
                , {field: 'ids', title: '序号/用户ID'}
                , {field: 'buy_type', title: '购买方式'}
                , {field: 'buy_nums', title: '购买次数'}
                , {field: 'vip_meal', title: '剩余天数/套餐'}
                , {field: 'create_time', title: '创建时间'}
                , {field: 'rightbtn', title: '操作', align: 'center', toolbar: '#barDemo'}
            ]],
            done: function (res) {
                var element = $('td[data-field="rightbtn"]').children('.layui-table-cell');
                element.css('overflow', 'visible');
                element.children('.dropdown-menu').css('min-width', 'auto');
            },
            parseData: function (res) {
                return {
                    "code": res.code,
                    "msg": res.msg,
                    "count": res.data.count,
                    "data": res.data.list
                };
            }
        });

        // 搜索
        $('#button-addon1').on('click', function () {
            var keywords = $("#keywords").val();
            table.reload('linkstable', {
                url: '{:url("/member/index")}'
                , where: {
                    keywords: keywords // 搜索参数
                }
                , page: {
                    curr: 1 //重新从第 1 页开始
                }
            });
        });

    });

    // 会员数据
    let labels = "{$member_data.usersMemberMonthLine.labels}";
    let datas = "{$member_data.usersMemberMonthLine.datas}";
    let dataDay = labels.split(',');
    let dataValue = datas.split(',');
    var ctx = document.getElementById("post");
    var data = {
        labels: dataDay,
        datasets: [
            {
                label: '',
                backgroundColor: '#F2FBFF',
                borderColor: "#5B78FF", //路径颜色
                pointBackgroundColor: "#5B78FF", //数据点颜色
                pointBorderColor: "#fff", //数据点边框颜色
                data: dataValue,
                borderWidth: '2',
                pointRadius: 0
            },
        ],
    };
    new Chart(ctx, {
        type: 'line',
        data: data,
        options: {
            legend: {display: false},
            scales: {
                yAxes: [{
                    tension: 0,
                    max: 50,
                    // 负数处理
                    ticks: {
                        beginAtZero: true,
                        userCallback: function (label, index, labels) {
                            // when the floored value is the same as the value we have a whole number
                            if (Math.floor(label) === label) {
                                return label;
                            }
                        },
                    }
                }],
                xAxes: [
                    {
                        gridLines: {display: false}
                    }
                ]
            }
        }
    });


    var chartDom = document.getElementById('state1');
    var myChart = echarts.init(chartDom);
    var option = {
        title: {
            //标题内容
            textStyle: {
                fontWeight: 'bold',
                fontFamily: 'Microsoft YaHei',
                fontSize: 24
            },
            //标题位置
            top: '5%',
            left: '5%'
        },
        //环形中间文字
        graphic: [
            //第一行文字
            //内容 + 位置
            {
                type: 'text',
                left: 'center',
                top: 'center',
                style: {
                    //value当前进度
                    text: "会员总数",
                    textAlign: 'center',
                    fill: '#0F1438',
                    fontSize: 16,
                    fontWeight: 'bold'
                }
            }
        ],
        series: [ //系列列表
            {
                name: '设备状态',  //系列名称
                type: 'pie',   //类型 pie表示饼图
                radius: ['70%', '64%'],//['外圆大小', '内圆大小']
                center: ['50%', '50%'],//圆心位置['左右'， '上下']
                // radius: ['70%', '90%'],  //饼图的半径,第一项是内半径,第二项是外半径,内半径为0就是真的饼,不是环形
                itemStyle: {  //图形样式
                    normal: { //normal 是图形在默认状态下的样式；emphasis 是图形在高亮状态下的样式，比如在鼠标悬浮或者图例联动高亮时。
                        label: {  //饼图图形上的文本标签
                            show: false  //平常不显示
                        },
                        labelLine: {     //标签的视觉引导线样式
                            show: false  //平常不显示
                        }
                    },
                },
                data: [
                    {value: "{$open_data.countUsersMember}"},
                ]
            }
        ]

    };
    myChart.setOption(option);

    // 月会员
    var chartDom = document.getElementById('state2');
    var myChart = echarts.init(chartDom);
    var option = {
        title: {
            //标题内容
            textStyle: {
                fontWeight: 'bold',
                fontFamily: 'Microsoft YaHei',
                fontSize: 24
            },
            //标题位置
            top: '5%',
            left: '5%'
        },
        //环形中间文字
        graphic: [
            //第一行文字
            //内容 + 位置
            {
                type: 'text',
                left: 'center',
                top: 'center',
                style: {
                    //value当前进度
                    text: "{$open_data.monthUsersMemberScale}",
                    textAlign: 'center',
                    fill: '#0F1438',
                    fontSize: 18,
                    fontWeight: 'bold'
                }
            }
        ],
        series: [{
            type: 'pie',
            radius: ['70%', '64%'],//['外圆大小', '内圆大小']
            center: ['50%', '50%'],//圆心位置['左右'， '上下']
            hoverAnimation: false,//取消鼠标悬停动画
            animationEasing: 'cubicOut',//设置动画缓动效果

            //取消显示饼图自带数据线条
            labelLine: {
                normal: {
                    show: false
                }
            },
            //增加阴影效果
            itemStyle: {
                normal: {
                    shadowBlur: 200,
                    shadowColor: 'rgba(44, 196, 196, 0.8)'
                }
            },
            data: [
                //value当前进度 + 颜色
                {
                    value: "{$open_data.monthUsersMember}",
                    itemStyle: {
                        normal: {
                            color: new echarts.graphic.LinearGradient(
                                0, 0, 0, 1,
                                [{offset: 0, color: '#FF4438'},
                                    {offset: 0.5, color: '#FFA13B'}])
                        }
                    }
                },
                //(maxValue进度条最大值 - value当前进度) + 颜色
                {
                    value: "{$open_data.lastMonthUsersMember}",
                    itemStyle: {
                        normal: {
                            color: '#E0E0E0'
                        }
                    }
                }
            ]
        }]
    };
    myChart.setOption(option);


    // 年会员
    var chartDom = document.getElementById('state3');
    var myChart = echarts.init(chartDom);
    var option = {
        title: {
            //标题内容
            textStyle: {
                fontWeight: 'bold',
                fontFamily: 'Microsoft YaHei',
                fontSize: 24
            },
            //标题位置
            top: '5%',
            left: '5%'
        },
        //环形中间文字
        graphic: [
            //第一行文字
            //内容 + 位置
            {
                type: 'text',
                left: 'center',
                top: 'center',
                style: {
                    //value当前进度
                    text: "{$open_data.yearsUsersMemberScale}",
                    textAlign: 'center',
                    fill: '#0F1438',
                    fontSize: 18,
                    fontWeight: 'bold'
                }
            }
        ],
        series: [{
            type: 'pie',
            radius: ['70%', '64%'],//['外圆大小', '内圆大小']
            center: ['50%', '50%'],//圆心位置['左右'， '上下']
            hoverAnimation: false,//取消鼠标悬停动画
            animationEasing: 'cubicOut',//设置动画缓动效果

            //取消显示饼图自带数据线条
            labelLine: {
                normal: {
                    show: false
                }
            },
            //增加阴影效果
            itemStyle: {
                normal: {
                    shadowBlur: 200,
                    shadowColor: 'rgba(44, 196, 196, 0.8)'
                }
            },
            data: [
                //value当前进度 + 颜色
                {
                    value: "{$open_data.yearsUsersMember}",
                    itemStyle: {
                        normal: {
                            color: new echarts.graphic.LinearGradient(
                                0, 0, 0, 1,
                                [{offset: 0, color: '#322FFD'},
                                    {offset: 0.5, color: '#00C7FF'}])
                        }
                    }
                },
                //(maxValue进度条最大值 - value当前进度) + 颜色
                {
                    value: "{$open_data.lastYearsUsersMember}",
                    itemStyle: {
                        normal: {
                            color: '#E0E0E0'
                        }
                    }
                }
            ]
        }]
    };
    myChart.setOption(option);

    //切换
    function commtype(t, e) {
        $('.sel-bottom').removeClass('avt');
        $(e).addClass('avt');
        type = t;
        keyword = '';
        $('input[name=keyword]').val('');
        window.history.replaceState(null, null, './index1.html?type=' + type);
    }
</script>
<style>
    .add {
        background: rgba(63, 110, 255, 0) !important;
        border: 1px solid #3F6EFF;
        border-radius: 6px;
        color: #3F6EFF !important;
    }

    .sel-dfx {
        display: flex;
        justify-content: space-between;
        margin: auto;
    }

    .sel-mat-top {
        margin-top: 40px;
        margin-bottom: 40px;
    }

    .avt {
        background: #3F6EFF !important;
        color: #FFFFFF !important;
    }

    .sel-bottom {
        background: #F0F0F0;
        padding: 10px 20px 10px 20px;
        border-radius: 3px;
        cursor: pointer;
        color: #999999;
    }

    .sel-bottom:active {
        background: #3377FF;
    }

    .card-dth {
        padding: 8px;
    }

    .user-name {
        font-size: 16px;
        font-family: 'AliM';
        font-weight: 500;
        color: #0E1525;
        margin-left: 10px;
        text-align: center;
    }

    .user {
        display: flex;
        justify-content: space-between;
    }

    .user {
        width: 96%;
        margin: auto;
        color: #0E1525;

    }

    .bg-txt {
        display: flex;
        margin-top: 5px;
    }


    .str {
        font-size: 12px;
        margin-left: 3px;
        color: #999999;
    }


    .d-fix {
        display: flex;
        justify-content: space-between;
        padding-top: 25px;
        padding-bottom: 20px;
    }

    .rig-img img {
        width: 9rem;
        height: 9rem;
    }

    .j {
        background: #5B78FF;
        width: 10px;
        height: 10px;
        margin-top: 3px;
    }

    .bz {
        background: #22b9ff;
        width: 10px;
        height: 10px;
        margin-top: 3px;
    }

    .dy {
        background: #28a745;
        width: 10px;
        height: 10px;
        margin-top: 3px;
    }

    .jn {
        background: #F74AFF;
        width: 10px;
        height: 10px;
        margin-top: 3px;
    }

    .bg-str {
        font-family: 'AliM';
        text-align: center;
    }

    .u-rig {
        display: flex;
        justify-content: center;
        width: 92%;
        margin: auto;
        padding-top: 10px;
        padding-bottom: 30px;
    }

    .u-left {
        margin-right: 25px;
    }

    .txt-cen {
        text-align: center;
    }

    .list {
        background: white;
        /*height: 100vh;*/
        padding: 20px;
        border-radius: 5px;
    }

    .uname {
        font-size: 18px;
        font-family: 'AliM';
        margin-bottom: 15px;
    }

    .fix-d {
        display: flex;
        justify-content: space-between;
        padding-bottom: 10px;
    }

    .d-th {
        padding-left: 10px;
        text-align: center;
    }

    .numer {
        font-size: 21px;
        font-family: 'AliM';
        font-weight: 600;
    }

    .t {
        color: #576AFB;
    }

    .d-str {
        font-size: 12px;
        font-family: 'AliM';
        margin-top: 5px;
    }

    .d-add {
        font-size: 11px;
        color: #999999;
        margin-top: 5px;
    }

    .b {
        color: #FF6739;
    }

    .w {
        color: #00A0FF;
    }

    .keword {
        display: flex;
    }

    .key-input {
        padding-left: 8px;
        border: 1px solid #e2d7d7;
        border-radius: 6px;
        width: 200px;
    }

    .key-bottom {
        margin-left: 10px;
        background: #007bff;
        padding-left: 20px;
        padding-right: 20px;
        border-radius: 34px;
        line-height: 30px;
        color: white;
        height: 30px;
        margin-top: 5px;
        cursor: pointer
    }

    .key-bottom:active {
        background: #71a2d8;
    }
</style>
</body>
</html>
